package com.woniuxy.creditsystem.statisticsmag.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.creditsystem.common.bean.OverdueStatisticsInfo;
import com.woniuxy.creditsystem.common.mapper.OverdueStatisticsMapper;
import com.woniuxy.creditsystem.statisticsmag.page.PageRequest;
import com.woniuxy.creditsystem.statisticsmag.service.IOverdueStatisticsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


/**
 * 逾期统计serviceimpl
 *
 * @author 刘川
 */

@Transactional(readOnly = true)
@Service
public class OverdueStatisticsServiceImpl implements IOverdueStatisticsService {
    @Resource
    private OverdueStatisticsMapper overdueStatisticsMapper;


    /**
     * 分页查询逾期统计表
     * @param request               分页的请求对象
     * @param overdueStatisticsInfo 分页条件
     * @return
     */
    @Override
    public PageInfo<OverdueStatisticsInfo> findAllByParams(PageRequest request, OverdueStatisticsInfo overdueStatisticsInfo) {
        return PageHelper.startPage(request.getPageNum(),request.getLimit()).
                doSelectPageInfo(()->overdueStatisticsMapper.findAllByParams(request,overdueStatisticsInfo));
    }

    /**
     * 新增逾期数据(定时任务)
     * @param overdueStatisticsInfo 添加对象
     * @return 影响行数
     */
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int saveOverdueStatistices(OverdueStatisticsInfo overdueStatisticsInfo) {

        return overdueStatisticsMapper.saveOverdueStatistices(overdueStatisticsInfo);
    }




}
